﻿/*******************************************************
* Autor: Oleg Rukin aka Keyki
********************************************************/

using System.Runtime.Serialization;
using System.Xml;

namespace Keyki.InitData
{
	[DataContract]
	public struct SOutData
	{
		private static DataContractSerializer _serializer;

		[DataMember]
		public double[][][] Params;
		[DataMember]
		public double Time;
		[DataMember]
		public double Error;
		//public string[] Rules;

		

		static public void Serialize(ref SOutData outData, string filename)
		{
			var settings = new XmlWriterSettings
			                             	{
			                             		Indent = true,
			                             		IndentChars = "  ",
			                             		NewLineOnAttributes = true
			                             	};
			XmlWriter writer = XmlWriter.Create(filename, settings);

			_serializer = new DataContractSerializer(typeof(SOutData));
			_serializer.WriteObject(writer, outData);

			writer.Close();
		}

		static public void Deserialize(ref SOutData outData, string filename)
		{
			XmlReader reader = new XmlTextReader(filename);
			_serializer = new DataContractSerializer(typeof(SOutData));
			var rez = _serializer.ReadObject(reader);

			outData = (SOutData)rez;

			reader.Close();
		}

	}
}